package graphic;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;

public class Knoten {

	public static final Color INIT_COL=Color.gray;
    public static final int   INIT_FUELLGR=8;
    
    public static final Color PREL_KNOWN_COL=Color.YELLOW;
    public static final int   PREL_KNOWN_FUELLGR=2;
    
	public static final Color KNOWN_COL=Color.blue;
    public static final int   KNOWN_FUELLGR=4;
    
    public static final Color START_COL=Color.RED;
    public static final int   START_FUELLGR=2;
    
    public static final Color HIND_COL=Color.BLACK;
    public static final int   HIND_FUELLGR=2;
    
    public static final Color TARGET_COL=Color.GREEN;
    public static final int   TARGET_FUELLGR=2;
    
	Color status; 
	int fuellungsGrad;
	Color nextStatus;
	int nextFuellGrad;
	int posX;
	int posY;
	int gitterPosX;
	int gitterPosY;
	int radius;
	double distanceFromStart=1000000000.0;
	double luftlinie2Target;
	
	Knoten proCameFrom;
	Knoten cameFrom;
		
        
	public Knoten (Color status, int fuellungsGrad, int posX, int posY, int radius) {
		this.status=status;
		this.posX=posX;
		this.posY=posY;
		this.radius=radius;
                this.fuellungsGrad=fuellungsGrad;
	}
        
        public void draw(Graphics g, Graphics2D g2) {        	
            g.setColor(status);
                for (int radX=1;radX<=radius;radX+=fuellungsGrad) {
        		Ellipse2D.Double ellipse = new Ellipse2D.Double(
        				radius/2+posX-radX/2,radius/2+posY-radX/2,radX, radX);        
        				g2.draw(ellipse);
                }
        }
        
        public String toString() {
    		return "posX="+gitterPosX+" posY="+gitterPosY+" status="+color2desc(status);
    	}
        
        public String color2desc(Color color) {
        	String retVal=null;
        	if (color==Color.red || color==Color.RED) retVal="red";
        	if (color==Color.blue || color==Color.BLUE) retVal="blue";
        	if (color==Color.black || color==Color.BLACK) retVal="black";
        	if (color==Color.yellow || color==Color.YELLOW) retVal="yellow";
        	if (color==Color.green || color==Color.GREEN) retVal="green";
        	if (color==Color.gray || color==Color.GRAY) retVal="gray";
        	if (retVal==null) retVal="unknown status";
        	return retVal;
        }
        
        public static double distance(Knoten k1, Knoten k2) {
        	return Board.neighourhoodDistance(
        			k1.gitterPosX, k1.gitterPosY, k2.gitterPosX, k2.gitterPosY);
        }
}
